﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

public partial class admin_news : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public void getTree() {
        StringBuilder sb = new StringBuilder();
        if (Session["admin"] != null && (Session["admin"].ToString().Equals("qiang") || Session["admin"].ToString().Equals("admin")))
        {
            DataTable dt = DB.getDataTable("select * from channel ");
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sb.Append("tree.nodes[\"" + dt.Rows[i]["father_id"].ToString() + "_" + dt.Rows[i]["channel_id"].ToString() + "\"] = \"text:" + dt.Rows[i]["name"].ToString() + ";method:sa('" + dt.Rows[i]["channel_id"].ToString() + "')\";");
                }
            }
        }
        else
        {
            DataTable dt = DB.getDataTable("select * from channel where channel_id in (select channelid from admin_qx where adminId=" + Session["adminId"] + ")");
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sb.Append("tree.nodes[\"1_" + dt.Rows[i]["channel_id"].ToString() + "\"] = \"text:" + dt.Rows[i]["name"].ToString() + ";method:sa('" + dt.Rows[i]["channel_id"].ToString() + "')\";");
                }
            }
        }
        Response.Write(sb.ToString());
    }
}
